package com.btrh.controller;

import com.btrh.util.R;
import exception.UserAlreadyDeleteException;
import exception.UserNotFoundExecption;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zyy
 * @date 2020/4/27 15:07
 * @description
 */
@RestController
@RequestMapping("test")
@Slf4j
public class TestController {


    @RequestMapping("1")
    public R test(int id){
        System.out.println("正在查询用户Id:" + id);

        System.out.println("用户查询完毕");
        if(id == 1){
            log.error("未查询到该用户，请重新核对!");
            throw new UserNotFoundExecption("未查询到该用户，请重新核对!");
        }
        if(id == 2){
            log.error("该用户已被注销");
            throw new UserAlreadyDeleteException("该用户已被注销");
        }
        try {
            int a =  10 / 0;
        } catch (Exception e) {
            e.printStackTrace();
            log.error("{}：{}",e.getClass(),e.getMessage());
            return R.failed();
        }
        return R.success("查询成功");
    }
}
